﻿@page "/Archive/Manufacturer/Index"
@page "/Archive/Manufacturer/Index/{Token}"
@using iTeamyou.LTS.UI.Models;
@using iTeamyou.LTS.UI.Shared.Components;

<h5 style="margin-top: 1.5rem;">管理生产商</h5>
<div style="margin-top: 2rem;">
    <Button Text="新建生产商" OnClick="@Add" IsDisabled="IsUnauth" />
    <Button Text="编辑" OnClick="@EditBtn" IsDisabled="@(SelectedManufacturers.Count != 1)" />
    <PopConfirmButton Color="Color.Danger" IsDisabled="@(SelectedManufacturers.Count == 0)" OnConfirm="(() => Delete(SelectedManufacturers))" ConfirmIcon="fa-solid fa-triangle-exclamation text-danger" ConfirmButtonColor="Color.Danger" Content="确定删除选中的记录吗？">删除</PopConfirmButton>
    <Button Text="导出" OnClick="@Export" IsDisabled="IsUnauth" />
</div>
@*
*@
<Table style="margin-top: 1rem;" TItem="Core.Models.Manufacturer"
       IsPagination="true" PageItemsSource="@PageItemsSource" IsStriped="true" ShowLineNo="true"
       CustomerSearchModel="@ManufacturerSearchModel" SearchMode="SearchMode.Top" ShowSearchText="true" ShowSearch="true"
       OnDoubleClickRowCallback="@Edit"
       SelectedRows="@SelectedManufacturers" SelectedRowsChanged="@SelectChanged" IsMultipleSelect="true"
       ShowSkeleton="true" ShowResetButton="true" ShowEmpty="true"
       OnQueryAsync="@OnQueryAsync" IsAutoRefresh="@IsAutoRefresh" AutoRefreshInterval="2000">
    <TableColumns>
        <TableColumn @bind-Field="@context.MId" Width="80" />
        <TableColumn @bind-Field="@context.Name" Width="200" />
        <TableColumn @bind-Field="@context.ProductType" Width="100" />
        <TableColumn @bind-Field="@context.Register" Width="100" />
        <TableColumn @bind-Field="@context.ResponsiblePerson" Width="100" />
        <TableColumn @bind-Field="@context.CreatedOn" Width="80" Sortable="true" />
        <TableColumn @bind-Field="@context.LastModifiedOn" Width="80" Sortable="true" />
        <TableColumn @bind-Field="@context.LicenseNum" Width="80" Text="证照数">
            <Template Context="value">
                @if (value.Value == 0)
                {
                    <Tag Color="Color.Dark">共 0 个证照</Tag>
                }
                else
                {
                    <Tag Color="Color.Primary">共 @value.Value 个证照</Tag>
                }
            </Template>
        </TableColumn>
    </TableColumns>
    <CustomerSearchTemplate>
        @if (context is ManufacturerSearchModel model)
        {
            <ManufacturerSearch @bind-Value="@model" />
        }
    </CustomerSearchTemplate>
</Table>